
CREATE PROCEDURE [dbo].[PopulateDeedSettings] 
AS
BEGIN 
	DECLARE @ID int
	DECLARE IDs CURSOR LOCAL FOR 
		SELECT d.deed_id
		FROM [dbo].[Land] l
		join dbo.Deed d on(l.land_id = d.land_id)
		WHERE l.IsActive = 'Y' and l.[type] in ('U','T','L') and l.[type] in ('L')

	OPEN IDs
	FETCH NEXT FROM IDs into @ID
	WHILE @@FETCH_STATUS = 0
	BEGIN	
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[IsHouse],[IsHotel],[IsUndevelopedColorMatch],[Count],[Rent]) VALUES(@ID,'N','N','Y',0,6);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[IsHouse],[IsHotel],[IsUndevelopedColorMatch],[Count],[Rent]) VALUES(@ID,'Y','N','N',1,10);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[IsHouse],[IsHotel],[IsUndevelopedColorMatch],[Count],[Rent]) VALUES(@ID,'Y','N','N',2,20);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[IsHouse],[IsHotel],[IsUndevelopedColorMatch],[Count],[Rent]) VALUES(@ID,'Y','N','N',3,30);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[IsHouse],[IsHotel],[IsUndevelopedColorMatch],[Count],[Rent]) VALUES(@ID,'Y','N','N',4,40);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[IsHouse],[IsHotel],[IsUndevelopedColorMatch],[Count],[Rent]) VALUES(@ID,'N','Y','N',1,50);

		FETCH NEXT FROM IDs into @ID
	END

	CLOSE IDs
	DEALLOCATE IDs



	DECLARE IDs CURSOR LOCAL FOR 
		SELECT d.deed_id
		FROM [dbo].[Land] l
		join dbo.Deed d on(l.land_id = d.land_id)
		WHERE l.IsActive = 'Y' and l.[type] in ('U','T','L') and l.[type] in ('T')

	OPEN IDs
	FETCH NEXT FROM IDs into @ID
	WHILE @@FETCH_STATUS = 0
	BEGIN
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[Count],[Rent]) VALUES(@ID,1,25);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[Count],[Rent]) VALUES(@ID,2,50);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[Count],[Rent]) VALUES(@ID,3,75);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[Count],[Rent]) VALUES(@ID,4,100);
		FETCH NEXT FROM IDs into @ID
	END

	CLOSE IDs
	DEALLOCATE IDs
	
	DECLARE IDs CURSOR LOCAL FOR 
		SELECT d.deed_id
		FROM [dbo].[Land] l
		join dbo.Deed d on(l.land_id = d.land_id)
		WHERE l.IsActive = 'Y' and l.[type] in ('U','T','L') and l.[type] in ('U')

	OPEN IDs
	FETCH NEXT FROM IDs into @ID
	WHILE @@FETCH_STATUS = 0
	BEGIN
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[Count],Multiplier) VALUES(@ID,1,4);
		INSERT INTO [dbo].[DeedSetting]([Deed_ID],[Count],Multiplier) VALUES(@ID,1,10);
		FETCH NEXT FROM IDs into @ID
	END

	CLOSE IDs
	DEALLOCATE IDs

END

-- [dbo].[PopulateDeedSettings]

